<footer id="page-footer" class="bg-body-light">
    <div class="content py-3">
        <div class="row font-size-sm">
            <div class="col-sm-6 order-sm-2 py-1 text-center text-sm-right">
                Crafted with <i class="fa fa-heart text-danger"></i> by <a class="font-w600" href="https://1.envato.market/ydb" target="_blank">pixelcave</a>
            </div>
            <div class="col-sm-6 order-sm-1 py-1 text-center text-sm-left">
                <a class="font-w600" href="https://1.envato.market/xWy" target="_blank">OneUI 4.0</a> © <span data-toggle="year-copy" class="js-year-copy-enabled">2018</span>
            </div>
        </div>
    </div>
</footer>


<div class="modal fade" id="modal-update-password" tabindex="-1" role="dialog" aria-labelledby="modal-update-password">
    <div class="modal-dialog modal-dialog-top" role="document">
        <div class="modal-content">
            <form id="form-update-password" action="" method="POST" onsubmit="return false;">
                <div class="block block-themed block-transparent mb-0">
                    <div class="block-header bg-primary">
                        <h3 class="block-title">
                            <i class="fa fa-pencil-alt mr-1"></i> 修改个人密码
                        </h3>
                        <div class="block-options">
                            <button type="button" class="btn-block-option" data-dismiss="modal" aria-label="Close">
                                <i class="fa fa-fw fa-times"></i>
                            </button>
                        </div>
                    </div>
                    <div class="block-content">
                        <div class="form-group">
                            <label for="old_password">原密码</label>
                            <input class="form-control" type="password" id="old_password" name="old_password" required>
                        </div>
                        <div class="form-group">
                            <label for="new_password">新密码</label>
                            <input class="form-control" type="password" id="new_password" name="new_password" required placeholder="密码长度为6-15个字符，建议包含大小写、特殊字符">
                        </div>

                    </div>
                    <div class="block-content block-content-full text-right border-top">
                        <button type="button" class="btn btn-sm btn-link mr-2" data-dismiss="modal">取 消</button>
                        <button type="submit" class="btn btn-sm btn-primary">
                            提 交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    $(function () {
        $("#form-update-password").submit(function () {
            var obj = $(this).find("input").serializeObject();
            obj._token = '{{ csrf_token() }}';
            $.ajax({
                url: '/perm/user/password',
                type: 'POST',
                data: obj,
                success: function (res) {
                    if(res.code === 200) {
                        Swal({
                            type: 'success',
                            title: '修改成功！',
                        });
                        $('#modal-update-password').modal('hide');
                    } else {
                        Swal({
                            type: 'error',
                            title: '修改失败！',
                            text: res.message,
                        });
                    }
                }
            });
        });
        $('#modal-update-password ').on('hidden.bs.modal', function (e) {
            document.getElementById("form-update-password").reset();
        })
    });
</script>
